# Contributor: George Hopkins <george-hopkins@null.net>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=imhex
pkgver=1.32.1
pkgrel=0
pkgdesc="Hex editor for reverse engineers and programmers"
url="https://github.com/WerWolv/ImHex"
# armhf, armv7, x86: 32-bit not supported
arch="all !armhf !armv7 !x86"
license="GPL-2.0-or-later"
options="!check" # No testsuite
makedepends="
	capstone-dev
	cmake
	curl-dev
	file-dev
	fmt-dev
	freetype-dev
	glfw-dev
	glm-dev
	gtk+3.0-dev
	libarchive-dev
	llvm-dev
	llvm-gtest
	llvm-static
	mbedtls-dev
	nlohmann-json
	openssl-dev
	python3-dev
	samurai
	yara-dev
	"
subpackages="$pkgname-doc"
source="$pkgname-$pkgver.tar.gz::https://github.com/WerWolv/ImHex/releases/download/v$pkgver/Full.Sources.tar.gz
	$pkgname-patterns-$pkgver.tar.gz::https://github.com/WerWolv/ImHex-Patterns/archive/refs/tags/ImHex-v$pkgver.tar.gz
	fix-lfs64.patch
	no-werror.patch
	"
builddir="$srcdir/ImHex"

prepare() {
	default_prepare

	mv -v "$srcdir"/ImHex-Patterns-ImHex-v$pkgver/ \
		ImHex-Patterns
}

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=Release \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DUSE_SYSTEM_CAPSTONE=ON \
		-DUSE_SYSTEM_NLOHMANN_JSON=ON \
		-DUSE_SYSTEM_FMT=ON \
		-DUSE_SYSTEM_LLVM=ON \
		-DUSE_SYSTEM_YARA=ON \
		-DIMHEX_DISABLE_STACKTRACE=ON \
		-DIMHEX_IGNORE_BAD_CLONE=ON \
		-DIMHEX_OFFLINE_BUILD=ON \
		-DIMHEX_STRIP_RELEASE=OFF \
		-DIMHEX_USE_GTK_FILE_PICKER=ON
	cmake --build build
}

package() {
	DESTDIR="$pkgdir" cmake --install build

	cd "$pkgdir"
	rm -rf usr/share/imhex/sdk
}

sha512sums="
a25c81c4c711beb1ad6ca20fbad9eeef16805c88f93b94501f20c13c73933c7022df2634f98cd7e8b1bc129ca1d62220bc14564e0a1543cb2d678afea9920af8  imhex-1.32.1.tar.gz
0a421a0c415f5c4d38e1acffe1adab2c0c5d4411635e916477efd1ceb03b7aa291a0af8360574b0e66e7e6b96895e3ff09246a7aa10f807c03f5806214cda5f1  imhex-patterns-1.32.1.tar.gz
dac50a201ba6e7da7578fd6b74b6c6accdb95934fe5807483959b8c5474e5ac0e9dcd10001358f60929a05c6331991c45838da710e6125d6f75f45ba0929a13c  fix-lfs64.patch
7882b0cc1fe1c620de0757f1a2b5893b7ff395479aa870719e0662dc11625c2929e786412d9031df9653257e76edd0292a3d50492f072b2ab275e46e75c3e441  no-werror.patch
"
